package great.easychat.help.dialog

import android.app.Dialog
import android.content.Context
import android.text.TextUtils
import great.easychat.help.R
import kotlinx.android.synthetic.main.dialog_progress.*

/**
 * @author athoucai
 * @date 2019/2/18
 */
class LoadDialog(context: Context?) : Dialog(context!!, R.style.TranslucentDialog) {

    init {
        setContentView(R.layout.dialog_progress)
        setCancelable(true)
        setCanceledOnTouchOutside(true)
    }

    fun showOnce(title: String? = null) {
        var sameTitle = TextUtils.equals(title, loadingTitle.text.toString())
        if (isShowing && sameTitle) {
            return
        }
        if (isShowing) {
            dismiss()
        }
        show(title)
    }

    fun show(title: String? = null) {
        loadingTitle.text = title
        show()
    }

    override fun show() {
        super.show()
    }
}